package com.treasure.mall.biz.service.core.auction;

import com.treasure.mall.biz.base.SearchableCrudService;
import com.treasure.mall.biz.entity.auction.AuctionBidLogPO;
import com.treasure.mall.biz.entity.auction.AuctionSessionPO;
import com.treasure.mall.biz.entity.user.UserPO;
import org.springframework.data.domain.Page;

import java.math.BigDecimal;

/**
 * @author allan
 * @version 1.0.0
 * @date 2020/7/16
 */
public interface AuctionSessionService extends SearchableCrudService<AuctionSessionPO, Long> {
    /**
     * 拍卖开始
     *
     * @param sessionId
     */
    void start(Long sessionId);

    void end(Long sessionId);


    /**
     * 拍卖出价
     *
     * @param userPO
     * @param sessionId
     */
    AuctionSessionPO bid(UserPO userPO, Long sessionId);

    /**
     * 最新的拍卖场次
     *
     * @param productId
     * @return
     */
    AuctionSessionPO currentSession(Long productId);

    /**
     * 需要缴纳的保证金
     *
     * @param userId
     * @param sessionId
     * @return
     */
    BigDecimal securityDeposit(Long userId, Long sessionId);

    /**
     * 是否可以出价
     *
     * @param userId
     * @param sessionId
     * @return
     */
    boolean enableBid(Long userId, Long sessionId);

    /**
     * 初始化定时任务
     */
    void initSchedule();

    /**
     * 退还保证金
     *
     * @param sessionId
     */
    void refund(Long sessionId);

    Page<AuctionBidLogPO> bidLogs(int pageIndex, int pageSize, Long sessionId);
}
